package com.mingqijia.gassafety.authority.api.web.facade;

import com.mingqijia.gassafety.authority.api.req.manager.ChangePasswordReqDTO;
import com.mingqijia.gassafety.authority.api.req.manager.CreateManagerReqDTO;
import com.mingqijia.gassafety.authority.api.req.manager.QueryManagerReqDTO;
import com.mingqijia.gassafety.authority.api.req.manager.UpdateManagerReqDTO;
import com.mingqijia.gassafety.authority.api.resp.manager.ManagerRespDTO;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * REST接口
 * @author Damon S.
 * @version v0.2
 * @date 2021-06-19
 */
@Api(tags = "控制台--用户")
@RequestMapping(value = "/console/v1/managers", produces = MediaType.APPLICATION_JSON_VALUE)
public interface ManagerManageFacade {

    @GetMapping
    @ApiOperation(value = "查询账户", notes = "返回用户列表")
    PageUtil<ManagerRespDTO> findManager(@Valid QueryManagerReqDTO req);

    @PostMapping
    @ApiOperation(value = "创建账户", notes = "返回是否创建成功")
    String createManager(@RequestBody@Valid CreateManagerReqDTO req);

    @PutMapping("/password/change")
    @ApiOperation(value = "变更密码(提交32位md5编码字符)", notes = "返回是否成功")
    void changePassword(@RequestBody@Valid ChangePasswordReqDTO req);

    @PutMapping("/password/reset")
    @ApiImplicitParam(name = "userId", value = "用户Id", dataType = "String")
    @ApiOperation(value = "重置密码", notes = "返回是否成功")
    void resetPassword(@RequestParam("userId") String userId);

    @PutMapping
    @ApiOperation(value = "更新账户", notes = "返回是否更新成功")
    void updateManager(@RequestBody@Valid UpdateManagerReqDTO req);

    @DeleteMapping
    @ApiImplicitParam(name = "userId", value = "账户Id列表", dataType = "Array")
    @ApiOperation(value = "删除账户", notes = "返回是否删除成功")
    void removeManager(String[] userId);

    @PutMapping("/{userId}/{state}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "账户Id(多个逗号分隔)", dataType = "String"),
            @ApiImplicitParam(name = "state", value = "启用状态", dataType = "String")
    })
    @ApiOperation(value = "账户激活(0冻结，1激活)", notes = "返回是否成功")
    void switchManager(@PathVariable String userId, @PathVariable Integer state);
}
